package com.guigu.zj.controller;

import com.guigu.pojo.Food;
import com.guigu.zj.pojo.PageVo;
import com.guigu.zj.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FoodController {
    @Autowired
    FoodService foodService;
    @RequestMapping("/Z_queryAll")
        public PageVo<Food>queryAll(@RequestBody PageVo<Food> pageVo){
            System.out.println(pageVo);
             return  foodService.queryAll(pageVo);
        }
    @RequestMapping("/Z_add")
        public int add(@RequestBody Food food){
            return foodService.insertSelective(food);
    }

    @RequestMapping("/Z_queryId")
    public Food queryId(@RequestBody Food food){
      return  foodService.selectByPrimaryKey(food.getId());
    }
    @RequestMapping("/Z_up")
    public int up(@RequestBody Food food){
       return foodService.updateByPrimaryKeySelective(food);
    }
    @RequestMapping("Z_del")
    public int del(Integer id){
        return foodService.deleteByPrimaryKey(id);
    }
}
